#pragma once

//Base class for all iterators of my-series.
template<class T>class myiter{
protected:
	T *pointer=nullptr;
public:
	virtual ~myiter()=0;
	virtual T& operator*(){return (*pointer);}
	virtual void operator++(){++pointer;}
	virtual void operator++(int){pointer++;}
	virtual void operator+=(int x){pointer+=x;}
	virtual void operator--(){--pointer;}
	virtual void operator--(int){pointer--;}
	virtual void operator-=(int x){pointer-=x;}
	virtual void operator=(const myiter<T> &x){pointer=x.pointer;}
	virtual bool operator==(const myiter<T> &x)const{return (pointer==x.pointer);}
	virtual bool operator<(const myiter<T> &x)const{return (pointer<x.pointer);}
	virtual bool operator>(const myiter<T> &x)const{return (pointer>x.pointer);}
	virtual bool operator<=(const myiter<T> &x)const{return (pointer<=x.pointer);}
	virtual bool operator>=(const myiter<T> &x)const{return (pointer>=x.pointer);}
	virtual bool operator!=(const myiter<T> &x)const{return (pointer!=x.pointer);}
	virtual bool isempty()const{return (pointer==nullptr);}
};
template<class T>myiter<T>::~myiter(){}
template<class K,class V>class mypair{
public:
	K key;
	V value;
};
template<class T>inline void myswap(T &a,T &b){T c=a;a=b;b=c;}
template<class T>inline T mymin(T a,T b,bool xydy(T c,T d)=[](T e,T f)->bool{return (e<=f);}){
	return xydy(a,b)?a:b;
}
template<class T>inline T mymax(T a,T b,bool xydy(T c,T d)=[](T e,T f)->bool{return (e<=f);}){
	return xydy(a,b)?b:a;
}
inline int aver(const int &x,const int &y){return (x&y)+((x^y)>>1);}
